<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/12
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>评选结果</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn {
        text-align: right;
    }
    .layui-form-item {
        margin-bottom: 5px;
    }
    .layui-input-inline{
        width: 300px !important;
    }
    .layui-icon-ok{
        margin-top: 6px;
    }
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
    .item{
        height: 40px;
        line-height: 47px;
        margin-left: 30px;
    }
</style>
<body>
<div>
    <div class="item">
        <span  style="font-size: 22px;display: inline-block;vertical-align: middle;">评选结果(院学术委员会秘书处)</span>
    </div>
    <hr class="layui-bg-blue">
    <div>
        <div class="btn">
            <div style="margin-left: 10px;float: left" class="layui-form">
                <input type="radio" checked name="status" value="0" lay-filter="trOtherNull" title="未审核">
                <input type="radio" name="status" value="1"  lay-filter="trOtherNull" title="已审核">
            </div>
            <div>
                <button type="button" class="layui-btn immp layui-btn-sm " onclick="plSp()" style="margin-right: 15px">
                    批量审核
                </button>
                <button type="button" class="layui-btn immp layui-btn-sm " onclick="exportFun()" style="margin-right: 15px" >
                    <i class="layui-icon">&#xe601;</i>
                    导出
                </button>
            </div>
        </div>
    </div>
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>

</body>
</html>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">定级</a>
</script>
<script>
    function plSp(){
        var chooseArr = layui.table.checkStatus('test').data;
        if(chooseArr.length == 0){
            layer.alert('请至少选择一条任务！', {icon: 7})
        }else{
            var index = layui.layer.open({
                type: 1,
                title:'审核',
                btn: ['确定', '返回'],
                area: ['40%', '50%'],
                content: '<div id="cont" style="margin: 10px">\n' +
                    '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <div class="layui-inline" style="width: 100%;"> \n' +
                    '                    <div class="layui-form-item layui-form-text">\n' +
                    '                        <label class="layui-form-label">审核意见:</label>\n' +
                    '                        <div class="layui-input-inline" style="width: calc(100% - 150px)!important;">\n' +
                    '                            <textarea placeholder="请输入内容" class="layui-textarea"  name="teacheerOpinion"></textarea>\n' +
                    '                        </div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    ' <div class="layui-form-item">\n' +
                    '    <label class="layui-form-label">设定领奖:</label>\n' +
                    '    <div class="layui-input-block">\n' +
                    '      <input type="radio" name="trOther" value="一等奖" title="一等奖" checked="">\n' +
                    '      <input type="radio" name="trOther" value="二等奖" title="二等奖">\n' +
                    '      <input type="radio" name="trOther" value="三等奖" title="三等奖">\n' +
                    '    </div>\n' +
                    '  </div>'+
                    '        </form>\n' +
                    '    </div>',
                success:function (res) {
                    layui.form.render();
                },
                yes:function (index, layero) {
                    var topicIds = '';
                    var planExt = '';
                    for(var i=0;i<chooseArr.length;i++){
                        if(chooseArr.length != i+1){
                            topicIds += chooseArr[i].topicId+',';
                            planExt += chooseArr[i].planExt+',';
                        }else{
                            topicIds += chooseArr[i].topicId;
                            planExt += chooseArr[i].planExt;
                        }
                    }
                    var trRemark = $('textarea[name=teacheerOpinion]').val();
                    var trOther = $('input[name="trOther"]:checked').val();
                    $.post('/rpmTopicRemark/addTopicRemark',{
                        topicIds:topicIds,
                        planExt:planExt,
                        trRemark:trRemark,
                        trOther:trOther,
                        trType:19,
                        trStatus:2
                    },function(res){
                        if(res.flag){
                            layer.alert('审核成功！', {icon: 1}, function(i){
                                layer.closeAll();
                            });
                        }else{
                            layer.alert('审核失败！', {icon: 2}, function(i){
                                layer.closeAll();
                            });
                        }
                    })
                },
                btn2:function (index, layero) {

                }
            })
        }

    }
    layui.use(['table', 'layer', 'form','laydate','upload'], function () {
        var table = layui.table
            , layer = layui.layer
            , form = layui.form
            , upload = layui.upload
            , laydate = layui.laydate
        $(document).ready(function(){
            form.render();
        });

        var tableInt = table.render({
            elem: '#test'
            ,url:"/rpmTopicRemark/selectPlanResults"
            ,where:{
                ctreateType:3,
                trOtherNull:0
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.data, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            , cols: [[
                {type: 'checkbox'},
                {field: 'planName', title: '任务名称', align: 'center'}
                , {field: 'topicName', title: '成果名称', align: 'center'}
                , {field: 'topicTypeName', title: '成果类型', align: 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                , {field: 'userName', title: '申报人姓名', align: 'center'}
                , {field: 'deptName', title: '科室', align: 'center'}
                , {field: 'userStatus', title: '申报状态', align: 'center'}
                , {field: 'trOther', title: '获奖等级', align: 'center'}
                , {field: 'savg', title: '平均分', align: 'center'}
                , {field: 'type', title: '定级修改', toolbar: '#barDemo'}
            ]],
            page:true
        });
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            var topicIds = data.topicId;
            var planExt = data.planExt;
             if(obj.event === 'edit'){
                 layer.open({
                     type: 1,
                     title:'审核',
                     btn: ['确定', '返回'],
                     area: ['40%', '50%'],
                     content: '<div id="cont" style="margin: 10px">\n' +
                         '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                         '            <div class="layui-form-item">\n' +
                         '                <div class="layui-inline" style="width: 100%;"> \n' +
                         '                    <div class="layui-form-item layui-form-text">\n' +
                         '                        <label class="layui-form-label">审核意见:</label>\n' +
                         '                        <div class="layui-input-inline" style="width: calc(100% - 150px)!important;">\n' +
                         '                            <textarea placeholder="请输入内容" class="layui-textarea"  name="teacheerOpinion"></textarea>\n' +
                         '                        </div>\n' +
                         '                    </div>\n' +
                         '                </div>\n' +
                         '            </div>\n' +
                         ' <div class="layui-form-item">\n' +
                         '    <label class="layui-form-label">设定领奖:</label>\n' +
                         '    <div class="layui-input-block">\n' +
                         '      <input type="radio" name="trOther" value="一等奖" title="一等奖" checked="">\n' +
                         '      <input type="radio" name="trOther" value="二等奖" title="二等奖">\n' +
                         '      <input type="radio" name="trOther" value="三等奖" title="三等奖">\n' +
                         '    </div>\n' +
                         '  </div>'+
                         '        </form>\n' +
                         '    </div>',
                     success:function (res) {
                         form.render();
                     },
                     yes:function (index, layero) {
                         var trRemark = $('textarea[name=teacheerOpinion]').val();
                         var trOther = $('input[name="trOther"]:checked').val();
                         $.post('/rpmTopicRemark/addTopicRemark',{
                             topicIds:topicIds,
                             planExt:planExt,
                             trRemark:trRemark,
                             trOther:trOther,
                             trType:19,
                             trStatus:2
                         },function(res){
                             if(res.flag){
                                 layer.alert('审核成功！', {icon: 1}, function(i){
                                     layer.closeAll();
                                 });
                             }else{
                                 layer.alert('审核失败！', {icon: 2}, function(i){
                                     layer.closeAll();
                                 });
                             }
                         })
                     },
                     btn2:function (index, layero) {

                     }
                 })
            }
        });

        // //监听顶部单选按钮
        form.on('radio(trOtherNull)', function(data){
            var value = data.value;
            table.reload('test', {
                where:{
                    trOtherNull:value
                }
            });
        });
    })

    function exportFun(){
        window.open('/rpmTopicRemark/selectPlanResults?trOtherNull=0&ctreateType=3&exportType=1');
    }
</script>
